/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.util.ArrayList;

/**
 *
 * @author Thai Ha Cong
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        ArrayList<Person> list = new ArrayList<>();
        
        Person p1 = new Person("Thai", 23);
        Person p2 = new Person("Binh", 15);
        list.add(p1);
        list.add(p2);
        
        System.out.println("---------------");
        for(Person p:list){
            System.out.println(p.toString());
        }
        
        Person p3 = new Person("Binh", 2);
        Person pp;
        if (list.contains(p3)) {
            System.out.println("1");
            pp = list.get(list.indexOf(p3));
            pp.setAge(pp.getAge() + p3.getAge());
            pp.setAge(25);
        }
        
        System.out.println("---------------");
        for(Person p:list){
            System.out.println(p.toString());
        }
    }
}
